@extends('Home.Index.index')
@section('title')
    个人中心
@endsection
@section('content')
    <section id="main">
        <div class="container_12">
            <div id="sidebar" class="grid_3">
                <aside id="categories_nav">
                    <h3>用户中心</h3>

                    <nav class="left_menu">
                        <ul>
                            <li><a href="{{url('/user_info/')}}">个人信息</a></li>
                            <li><a href="{{url('/user_address/')}}">收货地址管理</a></li>
                            <li><a href="{{url('/user_address_list/')}}">我的收货地址</a></li>
                            <li><a href="{{url('/user_order/')}}">我的订单</a></li>
                        </ul>
                    </nav><!-- .left_menu -->
                </aside><!-- #categories_nav -->

                {{--<aside id="manufacturers">--}}

                {{--</aside><!-- #categories_nav -->--}}

                {{--<aside id="tags">--}}

                {{--</aside><!-- #tags -->--}}

                {{--<aside id="newsletter_signup">--}}

                {{--</aside><!-- #newsletter_signup -->--}}

            </div><!-- .sidebar -->
            <div id="content" class="grid_9">
                <h1 class="page_title">欢迎来到用户中心</h1>
                <br>
                <article class="post">
                    {{--这里写用户信息列表--}}
                    @if(empty($member_info))
                    <form action="" method="post">
                        <p>
                            <label>真实姓名：</label>
                            <input  type="text" name="username" id="username" value="">
                        </p>
                        <p>
                            <label>性别：</label>
                            <label for="J_gender1" class="except">
                                <input  type="radio" name="sex" value="1" id="sex-1" />男
                            </label>
                            <label for="J_gender2" class="except">
                                <input  type="radio" name="sex" value="0" id="sex-2" checked="checked" />女
                            </label>
                        </p>
                        <p>
                            <label>身份证号码：</label>
                            <input id="id_number" class="f-txt" type="text" value="">
                        </p>
                        <p>
                            <label>邮箱：</label>
                            <input id="email" class="f-txt" type="text" value="">
                        </p>
                        <div class="submit">
                            <button type="button" class="btn met1" id="user_info_save">保存</button>
                        </div>
                    </form>
                        @else
                        <form action="" method="post">
                            @foreach($member_info as $info)
                            <p>
                                <label>真实姓名：</label>
                                <input  type="text" name="username" id="username" value="{{$info->real_name}}">
                            </p>
                            <p>
                                @if($info->sex == 1)
                                <label>性别：</label>
                                <label for="J_gender1" class="except">
                                    <input  type="radio" name="sex" value="1"  checked id="sex-1" />男
                                </label>
                                <label for="J_gender2" class="except">
                                    <input  type="radio" name="sex" value="0" id="sex-2"  />女
                                </label>
                                    @else
                                    <label>性别：</label>
                                    <label for="J_gender1" class="except">
                                        <input  type="radio" name="sex" value="1"   id="sex-1" />男
                                    </label>
                                    <label for="J_gender2" class="except">
                                        <input  type="radio" name="sex" value="0" id="sex-2" checked />女
                                    </label>

                                    @endif
                            </p>
                            <p>
                                <label>身份证号码：</label>
                                <input id="id_number" class="f-txt" type="text" value="{{$info->idcard}}">
                            </p>
                            <p>
                                <label>邮箱：</label>
                                <input id="email" class="f-txt" type="text" value="{{$info->email}}">
                            </p>
                            <div class="submit">
                                <button type="button" class="btn met1" id="user_info_save">保存</button>
                            </div>
                                @endforeach
                        </form>
                    @endif
                </article>
            </div>
        </div><!-- .container_12 -->
    </section><!-- #main -->

    <div class="clear"></div>

    {{--用户信息表单的js文件--}}
    <script>
        $('#user_info_save').click(function () {
            var realname = $('#username').val();
            var sex = $("input[name='sex']:checked").val();
            var idcard = $('#id_number').val();
            var email = $('#email').val();
            $.post('{{url('/user_info_add/')}}',{realname:realname,sex:sex,idcard:idcard,email:email},function (e) {
                console.log(e);
                if(e.status)
                {
                    layer.msg(e.info,{icon:6},function () {
                        window.location.reload();
                    });
                }else {
                    layer.msg(e.info,{icon:5});
                }

            });

        });

    </script>

@endsection